package com.wuxiaofan.product.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.product.entity.SpuInfo;
import com.wuxiaofan.product.entity.custom.SpuInfoCustom;
import com.wuxiaofan.product.mapper.SpuInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.product.client.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class SpuInfoService {
    @Autowired
    private SpuInfoMapper pmsSpuInfoMapper;
    @Resource
    private Idgenerator idgenerator;
    public SpuInfo findById(String id){
        return pmsSpuInfoMapper.selectById(id);
    }

    public SpuInfoCustom findCountByMap(Map paraMap){
        return pmsSpuInfoMapper.findCountByMap(paraMap);
    }

    public SpuInfoCustom findGroupByMap(Map paraMap){
        return pmsSpuInfoMapper.findGroupByMap(paraMap);
    }

    public List<SpuInfoCustom> findByMap(Map paraMap){
        return pmsSpuInfoMapper.findByMap(paraMap);
    }

    public Page<SpuInfoCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(pmsSpuInfoMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        pmsSpuInfoMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        pmsSpuInfoMapper.deleteById(id);
    }

    public SpuInfo save(SpuInfo pmsSpuInfo){
        pmsSpuInfo.setId(idgenerator.getId());
        pmsSpuInfoMapper.insert(pmsSpuInfo);
        return pmsSpuInfo;
    }

}
